package app;
import info.clearthought.layout.TableLayout;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ReportarBug extends javax.swing.JFrame {
	private JScrollPane jScrollPane1;
	private JButton enviar;
	private JTextArea contenido;
	private Main main;

	/**
	* Auto-generated main method to display this JFrame
	*/
		
	public ReportarBug(Main m) {
		super();
		initGUI();
		main=m;
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			TableLayout thisLayout = new TableLayout(new double[][] {{7.0, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, 7.0}, {7.0, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL}});
			thisLayout.setHGap(5);
			thisLayout.setVGap(5);
			getContentPane().setLayout(thisLayout);
			this.setTitle("Reportar bug");
			{
				jScrollPane1 = new JScrollPane();
				getContentPane().add(jScrollPane1, "1, 1, 5, 3");
				{
					contenido = new JTextArea();
					jScrollPane1.setViewportView(contenido);
					contenido.setPreferredSize(new java.awt.Dimension(334, 164));
				}
			}
			{
				enviar = new JButton();
				getContentPane().add(enviar, "3, 4, f, c");
				enviar.setText("Enviar");
				enviar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						enviarActionPerformed(evt);
					}
				});
			}
			pack();
			this.setSize(379, 296);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	private void enviarActionPerformed(ActionEvent evt) {
		try {
			main.reportarBug(contenido.getText());
			contenido.setText("");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			this.dispose();
		}
	}

}
